import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/constants/font_family.dart';
import 'package:flutter_eve_plugin/constants/font_weight.dart';
import 'package:flutter_eve_plugin/model/ye_xiu/achieves/archieves_role_entity.dart';
import 'package:flutter_eve_plugin/store/main.dart';
import 'package:flutter_eve_plugin/store_vm/app_vm.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';
import 'package:flutter_redux/flutter_redux.dart';

class ArchivesCenterTopContentWidget extends StatelessWidget {

  final ArchievesRoleRoleinfo info;
  final ArchievesRoleCardinfo cardinfo;

  const ArchivesCenterTopContentWidget({
    Key key,this.info,this.cardinfo
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, AppStateViewModel>(
        converter: (store) => AppStateViewModel(state: store.state),
        builder: (context, vm) {
          int fight = 0;
          if (info != null) {
            fight = info.upgradeFightingCapacity - info.fightingCapacity;
          }
//          print('${info?.upgradeFightingCapacity} - ${info?.fightingCapacity} - $fight');
          return Container(
            margin: EdgeInsets.only(top: setRatio(31), left: setRatio(26)),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                Container(
                  width: setRatio(65),
                  height: setRatio(18),
                  decoration: BoxDecoration(
                      color: Color(0x5F000000),
                      borderRadius: BorderRadius.circular(setRatio(3))),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      Text.rich(TextSpan(
                          style: TextStyle(
                              decoration: TextDecoration.none,
                              fontFamily: FontFamily.PMZD,
                              fontSize: setTextSp(12),
                              color: Color(0xFFFFFFFF)),
                          children: [
                            TextSpan(text: 'Lv.'),
                            TextSpan(
                                text: '${info.cardLevel.level}',
                                style: TextStyle(color: Color(0xFFFFBF13))),
                            TextSpan(text: '/' + '${cardinfo.maxLevel}')
                          ]))
                    ],
                  ),
                ),
                SizedBox(
                  width: setRatio(8),
                ),
                Text.rich(TextSpan(
                    style: TextStyle(
                        decoration: TextDecoration.none,
                        fontFamily: FontFamily.PINGFANG,
                        fontWeight: FontWeightCustom.PF_Medium,
                        fontSize: setTextSp(10),
                        color: Color(0xFFFFFFFF)),
                    children: [
                      TextSpan(text: '战斗力：'),
                      TextSpan(
                          text: '${info.fightingCapacity}',
                          style: TextStyle(
                              color: Color(0xFFFFBF13),
                              fontSize: setTextSp(12))),
                      TextSpan(
                          text:
                              ' +${fight > 0 ? fight : 0}',
                          style: TextStyle(
                              color: Color(0xFF62F488),
                              fontSize: setTextSp(11)))
                    ]))
              ],
            ),
          );
        });
  }
}
